

const p1 = () => new Promise((resolve) => setTimeout(() => {
    resolve("p1");
}, 1000))
const p2 = () => new Promise((resolve) => setTimeout(() => {
    resolve("p2");
}, 1000))
const p3 = () => new Promise((resolve) => setTimeout(() => {
    resolve("p3");
}, 1000))

//? async await
async function task() {
    //? 必须先同步赋值(相当于同时发送三个请求)
    const r1 =  p1()
    const r2 =  p2()
    const r3 =  p3()
    //? 再await等待三个结果返回
    await r1
    await r2
    await r3
    console.log('全部拿到')
}
// task()

//? promise

Promise.all([p1(),p2(),p3()]).then(res => console.log(res))
